//
//  AddChildView.m
//  IpadTestB
//
//  Created by edianzu on 2017/6/29.
//  Copyright © 2017年 ruilai. All rights reserved.
//

#import "AddChildView.h"

@implementation AddChildView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self creatUI];
    }
    return self;
}

-(void) creatUI{
    self.backgroundColor = [UIColor whiteColor];
    //上方绿色VIEW
    self.greenView = [[UIView alloc]init];
    self.greenView.backgroundColor = UIColorFromRGB(26, 167, 157);
    [self addSubview:self.greenView];
    [self.greenView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(self);
        make.height.mas_equalTo(40*AutoScaleVertical);
    }];
    //添加孩子
    self.addChildLabel = [[UILabel alloc]init];
    self.addChildLabel.text = @"添加孩子";
    self.addChildLabel.textColor = [UIColor whiteColor];
    [self.addChildLabel setTextAlignment:NSTextAlignmentCenter];
    self.addChildLabel.font = [UIFont boldSystemFontOfSize:20*AutoScaleHorizontal];
    [self.greenView addSubview:self.addChildLabel];
    [self.addChildLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.greenView.mas_centerX);
        make.centerY.mas_equalTo(self.greenView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(200*AutoScaleHorizontal, 20*AutoScaleVertical));
    }];
    //取消按钮
    self.cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.cancelBtn setImage:[UIImage imageNamed:@"cancelBtn"] forState:UIControlStateNormal];
    [self.greenView addSubview:self.cancelBtn];
    [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.addChildLabel.mas_centerY);
        make.right.mas_equalTo(self.greenView.mas_right).with.offset(-20*AutoScaleHorizontal);
        make.size.mas_equalTo(CGSizeMake(20*AutoScaleHorizontal, 20*AutoScaleVertical));
    }];
    //真实姓名
    self.realNameLabel = [[UILabel alloc]init];
    self.realNameLabel.text = @"真实姓名";
    self.realNameLabel.textColor = [UIColor blackColor];
    [self.realNameLabel setTextAlignment:NSTextAlignmentLeft];
    self.realNameLabel.font = [UIFont systemFontOfSize:18*AutoScaleHorizontal];
    [self addSubview:self.realNameLabel];
    [self.realNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.greenView.mas_bottom).with.offset(35*AutoScaleVertical);
        make.left.mas_equalTo(self.mas_left).with.offset(75*AutoScaleHorizontal);
        make.size.mas_equalTo(CGSizeMake(75*AutoScaleHorizontal, 20*AutoScaleVertical));
    }];
    
    _redStarLabel = [[UILabel alloc]init];
    _redStarLabel.textColor =[UIColor redColor];
    _redStarLabel.text = @"*";
    _redStarLabel.font = [UIFont systemFontOfSize:20*AutoScaleHorizontal];
    [self addSubview:_redStarLabel];
    [_redStarLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.realNameLabel.mas_right).with.offset(50*AutoScaleHorizontal);
        make.centerY.mas_equalTo(self.realNameLabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(15*AutoScaleHorizontal, 15*AutoScaleVertical));
    }];
    
    self.nameText = [[UITextField alloc]init];
//    self.nameText.delegate =self;
    self.nameText.layer.borderWidth = 1;
    self.nameText.placeholder = @"请输入孩子姓名";
    self.nameText.layer.borderColor =UIColorFromRGB(243, 243, 243).CGColor;
    [self addSubview:self.nameText];
    [self.nameText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_redStarLabel.mas_right).with.offset(5*AutoScaleHorizontal);
        make.centerY.mas_equalTo(self.realNameLabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(250*AutoScaleHorizontal, 30*AutoScaleVertical));
    }];
    
    //性别
    self.sexLabel = [[UILabel alloc]init];
    self.sexLabel.text = @"性别";
    self.sexLabel.textColor = [UIColor blackColor];
    [self.sexLabel setTextAlignment:NSTextAlignmentLeft];
    self.sexLabel.font = [UIFont systemFontOfSize:18*AutoScaleHorizontal];
    [self addSubview:self.sexLabel];
    [self.sexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.realNameLabel.mas_bottom).with.offset(30*AutoScaleVertical);
        make.left.mas_equalTo(self.mas_left).with.offset(75*AutoScaleHorizontal);
        make.size.mas_equalTo(CGSizeMake(75*AutoScaleHorizontal, 20*AutoScaleVertical));
    }];
    _redStarLabel1 = [[UILabel alloc]init];
    _redStarLabel1.textColor =[UIColor redColor];
    _redStarLabel1.text = @"*";
    _redStarLabel1.font = [UIFont systemFontOfSize:20*AutoScaleHorizontal];
    [self addSubview:_redStarLabel1];
    [_redStarLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.sexLabel.mas_right).with.offset(50*AutoScaleHorizontal);
        make.centerY.mas_equalTo(self.sexLabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(15*AutoScaleHorizontal, 15*AutoScaleVertical));
    }];
    self.boyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.boyBtn setTitle:@"男" forState:UIControlStateNormal];
    self.boyBtn.titleLabel.font =[UIFont systemFontOfSize:18*AutoScaleHorizontal];
    [self.boyBtn addTarget:self action:@selector(pressBoy) forControlEvents:UIControlEventTouchUpInside];
    [self.boyBtn setTitleColor:UIColorFromRGB(79, 79, 79) forState:UIControlStateNormal];
    [self.boyBtn setTitleColor:UIColorFromRGB(28, 137, 207) forState:UIControlStateSelected];
    self.boyBtn.selected = YES;
    [self.boyBtn setImage:[UIImage imageNamed:@"manIMG"] forState:UIControlStateNormal];
    [self.boyBtn setImage:[UIImage imageNamed:@"manIMGS"] forState:UIControlStateSelected];
    [self addSubview:self.boyBtn];
    [self.boyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_redStarLabel1.mas_right).with.offset(15*AutoScaleHorizontal);
        make.centerY.mas_equalTo(self.sexLabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(80*AutoScaleHorizontal, 30*AutoScaleVertical));
    }];
    
    self.girlBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.girlBtn addTarget:self action:@selector(pressGirl) forControlEvents:UIControlEventTouchUpInside];
    [self.girlBtn setTitle:@"女" forState:UIControlStateNormal];
    self.girlBtn.titleLabel.font =[UIFont systemFontOfSize:18*AutoScaleHorizontal];
    [self.girlBtn setTitleColor:UIColorFromRGB(79, 79, 79) forState:UIControlStateNormal];
    [self.girlBtn setTitleColor:UIColorFromRGB(236, 51, 102) forState:UIControlStateSelected];
    self.girlBtn.selected = NO;
    [self.girlBtn setImage:[UIImage imageNamed:@"womenIMG"] forState:UIControlStateNormal];
    [self.girlBtn setImage:[UIImage imageNamed:@"womenIMGS"] forState:UIControlStateSelected];
    [self addSubview:self.girlBtn];
    [self.girlBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.boyBtn.mas_right).with.offset(30*AutoScaleHorizontal);
        make.centerY.mas_equalTo(self.sexLabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(80*AutoScaleHorizontal, 30*AutoScaleVertical));
    }];
    
    
    //孩子生日
    self.birthdayLabel = [[UILabel alloc]init];
    self.birthdayLabel.text = @"孩子生日";
    self.birthdayLabel.textColor = [UIColor blackColor];
    [self.birthdayLabel setTextAlignment:NSTextAlignmentLeft];
    self.birthdayLabel.font = [UIFont systemFontOfSize:18*AutoScaleHorizontal];
    [self addSubview:self.birthdayLabel];
    [self.birthdayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.sexLabel.mas_bottom).with.offset(30*AutoScaleVertical);
        make.left.mas_equalTo(self.mas_left).with.offset(75*AutoScaleHorizontal);
        make.size.mas_equalTo(CGSizeMake(75*AutoScaleHorizontal, 20*AutoScaleVertical));
    }];
    _redStarLabel2 = [[UILabel alloc]init];
    _redStarLabel2.textColor =[UIColor redColor];
    _redStarLabel2.text = @"*";
    _redStarLabel2.font = [UIFont systemFontOfSize:20*AutoScaleHorizontal];
    [self addSubview:_redStarLabel2];
    [_redStarLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.birthdayLabel.mas_right).with.offset(50*AutoScaleHorizontal);
        make.centerY.mas_equalTo(self.birthdayLabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(15*AutoScaleHorizontal, 15*AutoScaleVertical));
    }];
    
    self.realBirthLabel = [[UILabel alloc]init];
    self.realBirthLabel.layer.borderWidth = 1;
    self.realBirthLabel.layer.borderColor =UIColorFromRGB(243, 243, 243).CGColor;
    [self.realBirthLabel setTextAlignment:NSTextAlignmentCenter];
    //    self.birthDayLabel.text = @"孩子生日";
    self.realBirthLabel.textColor = UIColorFromRGB(79, 79, 79);
    self.realBirthLabel.font = [UIFont systemFontOfSize:18*AutoScaleHorizontal];
    [self addSubview:self.realBirthLabel];
    [self.realBirthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_redStarLabel2.mas_right).with.offset(5*AutoScaleHorizontal);
        make.centerY.mas_equalTo(self.birthdayLabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(250*AutoScaleHorizontal, 30*AutoScaleVertical));
    }];
    
    self.realBirthBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.realBirthBtn.backgroundColor = [UIColor clearColor];
//    [self.realBirthBtn addTarget:self action:@selector(birthChoose) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.realBirthBtn];
    [self.realBirthBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(self.realBirthLabel);
    }];
    self.arrowView = [[UIImageView alloc]init];
    self.arrowView.image = [UIImage imageNamed:@"arrowView"];
    [self addSubview:self.arrowView];
    [self.arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.realBirthLabel.mas_right).with.offset(-15*AutoScaleHorizontal);
        make.centerY.mas_equalTo(self.realBirthLabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(10*AutoScaleHorizontal, 10*AutoScaleVertical));
    }];

    
    //所属班级
    self.classLabel = [[UILabel alloc]init];
    self.classLabel.text = @"所属班级";
    self.classLabel.textColor = [UIColor blackColor];
    [self.classLabel setTextAlignment:NSTextAlignmentLeft];
    self.classLabel.font = [UIFont systemFontOfSize:18*AutoScaleHorizontal];
    [self addSubview:self.classLabel];
    [self.classLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.birthdayLabel.mas_bottom).with.offset(30*AutoScaleVertical);
        make.left.mas_equalTo(self.mas_left).with.offset(75*AutoScaleHorizontal);
        make.size.mas_equalTo(CGSizeMake(75*AutoScaleHorizontal, 20*AutoScaleVertical));
    }];
    _redStarLabel3 = [[UILabel alloc]init];
    _redStarLabel3.textColor =[UIColor redColor];
    _redStarLabel3.text = @"*";
    _redStarLabel3.font = [UIFont systemFontOfSize:20*AutoScaleHorizontal];
    [self addSubview:_redStarLabel3];
    [_redStarLabel3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.classLabel.mas_right).with.offset(50*AutoScaleHorizontal);
        make.centerY.mas_equalTo(self.classLabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(15*AutoScaleHorizontal, 15*AutoScaleVertical));
    }];
    //家长电话
    self.phoneLabel = [[UILabel alloc]init];
    self.phoneLabel.text = @"家长电话";
    self.phoneLabel.textColor = [UIColor blackColor];
    [self.phoneLabel setTextAlignment:NSTextAlignmentLeft];
    self.phoneLabel.font = [UIFont systemFontOfSize:18*AutoScaleHorizontal];
    [self addSubview:self.phoneLabel];
    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.classLabel.mas_bottom).with.offset(30*AutoScaleVertical);
        make.left.mas_equalTo(self.mas_left).with.offset(75*AutoScaleHorizontal);
        make.size.mas_equalTo(CGSizeMake(75*AutoScaleHorizontal, 20*AutoScaleVertical));
    }];
    self.PhoneText = [[UITextField alloc]init];
    //    self.nameText.delegate =self;
    self.PhoneText.layer.borderWidth = 1;
    self.PhoneText.layer.borderColor =UIColorFromRGB(243, 243, 243).CGColor;
    [self addSubview:self.PhoneText];
    [self.PhoneText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.phoneLabel.mas_right).with.offset(70*AutoScaleHorizontal);
        make.centerY.mas_equalTo(self.phoneLabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(250*AutoScaleHorizontal, 30*AutoScaleVertical));
    }];
    
    //确定按钮
    self.confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.confirmBtn.backgroundColor =UIColorFromRGB(26, 167, 157);
    self.confirmBtn.layer.cornerRadius = 5;
    [self.confirmBtn setTitle:@"确定" forState:UIControlStateNormal];
    [self addSubview:self.confirmBtn];
    [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.top.mas_equalTo(self.phoneLabel.mas_bottom).with.offset(30*AutoScaleVertical);
        make.size.mas_equalTo(CGSizeMake(70*AutoScaleHorizontal, 30*AutoScaleVertical));
    }];
}




-(void)pressBoy{
    self.boyBtn.selected = YES;
    self.girlBtn.selected = NO;
//    [self.boyBtn setTitleColor:UIColorFromRGB(28, 137, 207) forState:UIControlStateNormal];
//    [self.girlBtn setTitleColor:UIColorFromRGB(79, 79, 79) forState:UIControlStateNormal];
}
-(void)pressGirl{
    self.boyBtn.selected = NO;
    self.girlBtn.selected = YES;
    
//    [self.boyBtn setTitleColor:UIColorFromRGB(79, 79, 79) forState:UIControlStateNormal];
//    [self.girlBtn setTitleColor:UIColorFromRGB(236, 51, 102) forState:UIControlStateNormal];
}
@end











